<extend file='resource/view/master'/>
<block name="content">
    <ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
        <li>
            <a href=""><i class="fa fa-cogs"></i>
                	货品管理
            </a>
        </li>
        <li class="active">
            <a href="">货品展示</a>
        </li>
    </ol>
    <ul class="nav nav-tabs" role="tablist">
        <li class="active"><a href="{{u('index')}}">货品管理</a></li>
    </ul>
    <form action="" method="post">
        <div class="panel panel-default">
            <div class="panel-body">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th width="80">货品编号</th>
                        <foreach from="$data" key="$k" value="$v">
                        <th>{{$v['taname']}}</th>
                        </foreach>
                        <th>货号</th>
                        <th>库存</th>
                        <th width="200">操作</th>
                    </tr>

                    </thead>
                    <tbody>
                    <foreach from="$loddata" key="$k" value="$v">
                        <tr>
                            <td>{{$v['glid']}}</td>
                                <foreach from="$v['combine']" key="$kk" value="$vv">
                                    <td>{{$vv}}</td>
                                </foreach>
                            <td>{{$v['number']}}</td>
                            <td>{{$v['inventory']}}</td>
                            <td>
                                <div class="btn-group">
                                    <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span></button>
                                    <ul class="dropdown-menu dropdown-menu-right">
                                        <li><a href="javascript:;" onclick="del({{$v['glid']}})">删除</a></li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </foreach>
                        <tr style="text-align: center">
                            <td>添加货品</td>
                            <foreach from="$data" key="$k" value="$v">
                                <td>
                                    <select name="spec[]">
                                        <option value="0">请选择</option>
                                        <foreach from="$data[$k]['select']" key="$kk" value="$vv" >
                                            <option value="{{$vv['gtid']}}">{{$vv['gtvalue']}}</option>
                                        </foreach>
                                    </select>
                                </td>
                            </foreach>
                            <td>
                                <input type="text"  class="form-control" name="number" value="">
                            </td>
                            <td>
                                <input type="text"  class="form-control" name="inventory" value="">
                            </td>
                            <input type="hidden" name="gid" value="{{q('get.gid')}}">
                            <td><button class="btn btn-primary" type="submit">确定</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </form>
</block>
<script>
    function del(glid) {
        var obj = util.modal({
            title:'确认删除？',//标题
            content:'',//内容
            footer:'<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button><button type="button" class="btn btn-danger confirm" data-dismiss="modal">删除</button>',//底部
            width:600,//宽度
            events:{
                confirm:function(){
                    //哪个元素上有.confirm类，被点击就执行这个回调
                    location.href = "{{u('del')}}" + '&glid=' + glid;
                }
            }
        });
        //显示模态框
        obj.modal('show');
    }
</script>